export default {
    data() {
        return {
            yzmBtn: {
                text: '发送验证码',
                time: 60,
                timeFn: null,
                disabled: false
            }
        }
    },
    methods: {
        getYzmFn() {
            let btn = this.yzmBtn
            if (btn.disabled) {
                return
            }
            const sTime = btn.time
            btn.disabled = true
            btn.time -= 1
            btn.text = `${btn.time}S后重新发送`
            btn.timeFn = setInterval(() => {
                btn.time -= 1
                btn.disabled = true
                if (btn.time <= 0) {
                    clearInterval(btn.timeFn)
                    btn.text = `发送验证码`
                    btn.disabled = false
                    btn.time = sTime
                    return false
                }
                btn.text = `${btn.time}S后重新发送`
            }, 1000)
        }
    }
}
